import { getAllDirectiveList, getStateList } from '@/api/manageEnd/propagandizeDirective/allDirective'
import { commandAbort } from '@/api/manageEnd/propagandizeDirective/pendingReviewDirective.js'

export default {
  methods: {
    async getAllDirectiveList(params) {
      this.tableLoading = true
      const res = await getAllDirectiveList(params)
      // console.log('getAllDirectiveList', res)
      const data = res.data.data || {}
      this.tableData = Object.freeze(data.data || [])
      this.pagination.total = data.count || 0
      this.tableLoading = false
    },

    async commandAbort(id) {
      const res = await commandAbort(id)
      const status = res.data.status
      if (status === 0) {
        this.$Message.success('操作成功')
        this.handleFormSubmit()
      } else {
        this.$Message.error(res.data.message || '操作失败，请稍后再试')
      }
    },

    // 获取状态列表
    async getStateList() {
      const res = await getStateList()
      this.directiveStates = res.data.data || []
    },
  },
}
